package org.ghost.wechat.platform.common.db;

import org.ghost.wechat.platform.common.enumeration.DbTypeEnum;

/**
 * @author Administrator
 */
public class DynamicDataSourceHolder {
    private static ThreadLocal<DbTypeEnum> contextHolder = new ThreadLocal<DbTypeEnum>();


    static DbTypeEnum getDbType() {
        DbTypeEnum dbType = contextHolder.get();
        if (dbType == null) {
            dbType = DbTypeEnum.MASTER;
        }
        return dbType;
    }


    static void setDbType(DbTypeEnum dbType) {
        contextHolder.set(dbType);
    }


    public static void clearDbType() {
        contextHolder.remove();
    }
}
